#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：spider_learning 
@File ：get_cookies.py
@IDE  ：PyCharm 
@Author ：李涵彬
@Date ：2024/5/7 上午10:25 
"""
import json

from selenium import webdriver

browser = webdriver.Chrome()
browser.get('https://www.bilibili.com/')
input("请输入任意键继续...")
print("字典长度:\n", len(browser.get_cookies()), browser.get_cookies())

with open("cookies_file.json", 'w') as file:
	json_cookie = json.dumps(browser.get_cookies())
	file.write(json_cookie)
print("cookies写入成功")

browser.delete_all_cookies()
